package com.chenyue.cm.base.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableSwaggerBootstrapUi;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUi
public class SwaggerConfiguration {

 
	@Bean(value = "portalApi")
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("捷登API")
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.chenyue.cm.api"))//要用sprongBoot内置的sweeager必须改括号里的路径）
				.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
				.build();
	}

	 private ApiInfo apiInfo() {
	     return new ApiInfoBuilder()
	     .title("chenyue-cm 接口文档 ")
	     .description("chenyue-cm-jiedeng")
	     .termsOfServiceUrl("http://localhost:7385/CM/doc.html") //要用springBoot内置的swagger必须改这里的端口与yml文件一致）
	     .contact(new Contact("chenyue", "www.baidu.com", "1148017805@qq.com"))
	     //.contact("18234095367@163.com")
	     .version("1.0")
	     .build();
	 }



//	@Bean(value = "pageApi")
//	public Docket createpageRestApi() {
//		return new Docket(DocumentationType.SWAGGER_2)
//				.apiInfo(apiInfo())
//				.groupName("首页api")
//				.select()
//				.apis(RequestHandlerSelectors.basePackage("com.chenyue.cm.modules.education.controller"))
//				.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//				.build();
//	}
}